package ai.masks;

import ai.Threat;
import model.Slot;

/**
 * Maschera:
 *       Y
 *     X
 *   -
 */
public class Slot2DMask2 extends Mask {

	@Override
	public Threat applyMask(Slot[][] board, int row, int col) {
		if(isMaskApplicable(row, col, board.length-1, board[0].length-1))
		{
			Slot s = board[row][col];
			if(board[row+1][col-1]==s && board[row+2][col-2]==Slot.FREE)
				return new Threat(row+2, col-2, s, isThreatPlayable(board, row+2, col-2));
			else
				return null;
		}
		else
			return null;
	}

	@Override
	protected int minRow(int boardRows, int boardCols) {
		return 0;
	}

	@Override
	protected int maxRow(int boardRows, int boardCols) {
		return boardRows-2;
	}

	@Override
	protected int minCol(int boardRows, int boardCols) {
		return 2;
	}

	@Override
	protected int maxCol(int boardRows, int boardCols) {
		return boardCols;
	}

}
